package com.sys.web.async;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sys.dao.impl.MsgDaoImpl;

import net.sf.json.JSONObject;

@WebServlet("/msgAsy")
public class MsgAsy extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String userId = request.getParameter("userId");
		String msg = request.getParameter("msg");
		System.out.println(userId + msg);
		Boolean b = null;
		try {
			b = new MsgDaoImpl().deleteMsg(userId, msg);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		Map<String, Boolean> map = new HashMap<>();
		map.put("isSuc", b);
		response.getWriter().write(JSONObject.fromObject(map).toString());
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}